<?php get_header(); ?>

<!-- BEGIN #wrap -->
<div id ="wrap">

<?php include (TEMPLATEPATH . "/col-left.php"); ?>

<!-- BEGIN #col-main -->
<div id="col-main">

<h3 class="sec-title">Article</h3>

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post">
<h2 class="post-title" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" title="Permanent link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
<?php the_tags('<p>Tags: ', ', ', '</p>'); ?> 
<div class="post-body">
<?php the_content('Continue reading'); ?>
<?php
$this_post = $post;
$category = get_the_category(); $category = $category[0]; $category = $category->cat_ID;
$posts = get_posts('numberposts=6&offset=0&orderby=post_date&order=DESC&category='.$category);
$count = 0;
foreach ( $posts as $post ) {
if ( $post->ID == $this_post->ID || $count == 5) {
unset($posts[$count]);
}else{
$count ++;
}
}
?>
<?php if ( $posts ) : ?>
<div class="post">
<h3>Related articles</h3>
<ul>
<?php foreach ( $posts as $post ) : ?>
<li><a href="<?php the_permalink() ?>" title="<?php echo trim(str_replace("\n"," ",preg_replace('#<[^>]*?>#si','',get_the_excerpt()))) ?>"><?php if ( get_the_title() ){ the_title(); }else{ echo "Untitled"; } ?></a> (<?php the_time('F jS, Y') ?>)</li>
<?php endforeach // $posts as $post ?>
</ul>
</div>
<?php endif // $posts ?>
<p class="post-meta-ind">
<span class="meta-name">Last Modified :</span> <span class="meta-detail"><?php the_time('F jS, Y') ?></span><br />
<span class="meta-name">Filed under :</span> <span class="meta-detail"><?php the_category(', ') ?></span><br />
<span class="meta-name">Navigate :</span> <span class="meta-detail"><?php previous_post('%','Previous post', 'no'); ?> / <?php next_post('%','Next post', 'no'); ?></span>
</p>
</div>
</div>
<?php endwhile; else: ?>

<p>Sorry, no posts matched your criteria.</p>

<?php endif; ?>

<?php comments_template(); ?>

</div>
<!-- END #col-main -->

<?php include (TEMPLATEPATH . "/col-right.php"); ?>

<?php get_footer(); ?>